* Apply to: roadmaps_1.dta
* Description:  Figure 5 in Roadmaps

clear

set more off


use "...\1805 Roadmaps\roadmaps_1.dta", clear


* Treatment variables

gen con = 0
replace con = 1 if ctr_marlee!=.

gen vgd = 0
replace vgd = 1 if vgd_marlee!=.

gen pty = 0
replace pty = 1 if pty_marlee!=.

gen psi = 0
replace psi = 1 if psi_marlee!=.

gen psp = 0
replace psp = 1 if psp_marlee!=.

gen an3 = 0
replace an3 = 1 if end_marlee!=.
replace an3 = 1 if end_ideo_marlee!=.


* Drop extraneous respondents

drop if (con==0 & pty==0 & an3==0 & vgd==0 & psi==0 & psp==0)


* Dependent variables

gen marlee = ctr_marlee
replace marlee = vgd_marlee if vgd==1
replace marlee = pty_marlee if pty==1
replace marlee = psi_marlee if psi==1
replace marlee = psp_marlee if psp==1
replace marlee = end_marlee if (an3==1 & end_marlee!=.)
replace marlee = end_ideo_marlee if (an3==1 & end_ideo_marlee!=.)

gen vote_marlee = 0
replace vote_marlee = 1 if marlee==1
replace vote_marlee = . if marlee==3

gen vote_leemar = 1
replace vote_leemar = 0 if marlee==1
replace vote_leemar = . if marlee==3


gen vote_spatial = 0
replace vote_spatial = 1 if vote_marlee==1 & d1<=0
replace vote_spatial = 1 if vote_marlee==0 & d1>=0
replace vote_spatial = 0 if marlee==3


* Treatment-Ideology interactins

gen con_D1 = con * d1
gen vgd_D1 = vgd * d1
gen pty_D1 = pty * d1
gen psi_D1 = psi * d1
gen psp_D1 = psp * d1
gen an3_D1 = an3 * d1


* Eliminate Politician Endorser treatment group

drop if an3==1
drop end_marlee end_ideo_marlee an3 an3_D1


* Partisanship, policy views aligned

gen mar_rein = 0
replace mar_rein = 1 if party=="Democrat" & d1<=0
replace mar_rein = . if party=="Republican"

gen lee_rein = 0
replace lee_rein = . if party=="Democrat"
replace lee_rein = 1 if party=="Republican" & d1>=0

gen can_rein = mar_rein
replace can_rein = lee_rein if can_rein==.


drop if (party=="Independent" | party=="Other")

set more off

*log using "...\1805 Roadmaps\Figure 5.log", replace

* T-tests for difference with control group

ttest vote_spatial if (con==1 | vgd==1) & can_rein==0, by(con)
ttest vote_spatial if (con==1 | pty==1) & can_rein==0, by(con)
ttest vote_spatial if (con==1 | psi==1) & can_rein==0, by(con)
ttest vote_spatial if (con==1 | psp==1) & can_rein==0, by(con)

ttest vote_spatial if (con==1 | vgd==1) & can_rein==1, by(con)
ttest vote_spatial if (con==1 | pty==1) & can_rein==1, by(con)
ttest vote_spatial if (con==1 | psi==1) & can_rein==1, by(con)
ttest vote_spatial if (con==1 | psp==1) & can_rein==1, by(con)


* T-tests for difference with voter guide treatment group

ttest vote_spatial if (vgd==1 | pty==1) & can_rein==0, by(vgd)
ttest vote_spatial if (vgd==1 | psi==1) & can_rein==0, by(vgd)
ttest vote_spatial if (vgd==1 | psp==1) & can_rein==0, by(vgd)

ttest vote_spatial if (vgd==1 | pty==1) & can_rein==1, by(vgd)
ttest vote_spatial if (vgd==1 | psi==1) & can_rein==1, by(vgd)
ttest vote_spatial if (vgd==1 | psp==1) & can_rein==1, by(vgd)

*log close


* Partisanship, policy views aligned

clear

import excel "...\1805 Roadmaps\Figure 5 ttests.xlsx", sheet("Sheet1") firstrow

drop if model==.
drop if model!=2

* Create black values to facilitate bar spacing

set obs 6
replace model = 2 in 6
replace treatment = "blank1" in 6
replace mean = 0 in 6
set obs 7
replace model = 2 in 7
replace treatment = "blank2" in 7
replace mean = 0 in 7
set obs 8
replace model = 2 in 8
replace treatment = "blank3" in 8
replace mean = 0 in 8
set obs 9
replace model = 2 in 9
replace treatment = "blank4" in 9
replace mean = 0 in 9


* Create order term

gen order1 = 0
replace order1 = 1 if treatment=="control"
replace order1 = 2 if treatment=="blank1"
replace order1 = 3 if treatment=="guide"
replace order1 = 4 if treatment=="blank2"
replace order1 = 5 if treatment=="party"
replace order1 = 6 if treatment=="blank3"
replace order1 = 7 if treatment=="perspat"
replace order1 = 8 if treatment=="blank4"
replace order1 = 9 if treatment=="perpty"


sort model order1


* Figure 5a (Proportion supporting more proximate candidate)

graph bar mean if model==2, ///
     over(order1, label(nolabels)) ///
     asyvars bargap(0) ylabel(0(.10)1.03) legend(off) ///
	 ytitle("") ///
	 bar(1, lcolor(black) bcolor(gs16)) ///
	 bar(3, lcolor(black) bcolor(gs6)) ///
	 bar(5, lcolor(black) bcolor(gs12)) ///
	 bar(7, lcolor(black) bcolor(gs0)) ///
	 bar(9, lcolor(black) bcolor(gs4)) ///
	 text(.80 6 "{bf:.73}", size(large)) ///
	 text(.75 28 "{bf:.68}", size(large)) ///
	 text(1.01 50 "{bf:.94 *#}", size(large)) ///
	 text(.88 72 "{bf:81}", size(large)) ///
	 text(.76 93 "{bf:.69}", size(large)) ///
	 text(-.08 6 "{bf:Control}" " ") ///
	 text(-.08 28 "{bf:Voter}" "{bf:Guide}") ///
	 text(-.08 50 "{bf:Party}" "{bf:Cue}") ///
	 text(-.08 72 "{bf:Spatial}" "{bf:Map}") ///
	 text(-.08 93 "{bf:Party +}" "{bf:Map}") ///
	 intensity(*0.9) scheme(s1color) ///
	 note(" " " " " ") ///
     graphregion(color(white)) plotregion(color(white))


* Partisanship, policy views conflict

clear

import excel "...\1805 Roadmaps\Figure 5 ttests.xlsx", sheet("Sheet1") firstrow

drop if model==.
drop if model!=1

* Create black values to facilitate bar spacing

set obs 6
replace model = 1 in 6
replace treatment = "blank1" in 6
replace mean = 0 in 6
set obs 7
replace model = 1 in 7
replace treatment = "blank2" in 7
replace mean = 0 in 7
set obs 8
replace model = 1 in 8
replace treatment = "blank3" in 8
replace mean = 0 in 8
set obs 9
replace model = 1 in 9
replace treatment = "blank4" in 9
replace mean = 0 in 9


* Create order term

gen order1 = 0
replace order1 = 1 if treatment=="control"
replace order1 = 2 if treatment=="blank1"
replace order1 = 3 if treatment=="guide"
replace order1 = 4 if treatment=="blank2"
replace order1 = 5 if treatment=="party"
replace order1 = 6 if treatment=="blank3"
replace order1 = 7 if treatment=="perspat"
replace order1 = 8 if treatment=="blank4"
replace order1 = 9 if treatment=="perpty"


sort model order1


* Figure 5b (Proportion supporting more proximate candidate)

graph bar mean if model==1, ///
     over(order1, label(nolabels)) ///
     asyvars bargap(0) ylabel(0(.10)1.03) legend(off) ///
	 ytitle("") ///
	 bar(1, lcolor(black) bcolor(gs16)) ///
	 bar(3, lcolor(black) bcolor(gs6)) ///
	 bar(5, lcolor(black) bcolor(gs12)) ///
	 bar(7, lcolor(black) bcolor(gs0)) ///
	 bar(9, lcolor(black) bcolor(gs4)) ///
	 text(.28 6 "{bf:.21}", size(large)) ///
	 text(.51 28 "{bf:.44 *}", size(large)) ///
	 text(.36 50 "{bf:.29}", size(large)) ///
	 text(.38 72 "{bf:.31}", size(large)) ///
	 text(.38 93 "{bf:.31}", size(large)) ///
	 text(-.08 6 "{bf:Control}" " ") ///
	 text(-.08 28 "{bf:Voter}" "{bf:Guide}") ///
	 text(-.08 50 "{bf:Party}" "{bf:Cue}") ///
	 text(-.08 72 "{bf:Spatial}" "{bf:Map}") ///
	 text(-.08 93 "{bf:Party +}" "{bf:Map}") ///
	 intensity(*0.9) scheme(s1color) ///
	 note(" " " " " ") ///
     graphregion(color(white)) plotregion(color(white))

* End
